from lxml import etree

text = """
   <ul id="myul">
    <li>
        <a href="101.html">毛衣101</a>
		<span>价格：</span>
		<span>98</span>
	</li>
	<li>
        <a href="102.html">毛衣102</a>
		<span>价格：</span><span>11</span>
	</li>
	<li>
        <a href="103.html">毛衣103</a>
		<span>价格：</span><span>123</span>
	</li>
</ul>
"""
root = etree.HTML(text)
# 1.获取 每个商品的名称
# 输出： ['毛衣101','毛衣102','毛衣103']
xpath1 = "//ul[@id='myul']/li/a/text()"
titleTextList = root.xpath(xpath1)
print(titleTextList)
# 2.获取 第1个商品的价格
# 输出： 98
xpath2 = "//ul[@id='myul']/li[1]/span[2]/text()"
price2Text = root.xpath(xpath2)
print(price2Text[0])
